import request from '@/utils/request'

export const login = function(data) {
  return request({
    method: 'POST',
    url: '/authorizations',
    data
  })
}

export const sendSms = function(data) {
  return request({
    method: 'GET',
    url: '/sms/codes/' + data
  })
}

// 1. 封装请求函数 并导出
export const getUser = function() {
  return request({
    method: 'GET',
    url: '/user'
  })
}

// 1. 封装 tabs 请求接口
export const getChannels = function() {
  return request({
    method: 'GET',
    // 1. 将 接口 url改成 请求 我的频道
    url: '/user/channels'
  })
}

export const addFollow = userId => {
  return request({
    method: 'POST',
    url: '/user/followings',
    data: {
      target: userId
    }
  })
}

export const deleteFollow = userId => {
  return request({
    method: 'DELETE',
    url: `/user/followings/${userId}`
  })
}

export const getUserProfile = () => {
  return request({
    method: 'GET',
    url: '/user/profile'
  })
}

export const setUserProfile = data => {
  return request({
    method: 'PATCH',
    url: '/user/profile',
    data
  })
}

export const setUserPhoto = data => {
  return request({
    method: 'PATCH',
    url: '/user/photo',
    data
  })
}
